package container.list;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.UUID;

public class T03_SynchronizedList {
    public static void main(String[] args) {
        List<String> list = new ArrayList<>();
        List<String> listSync = Collections.synchronizedList(list);

        for (int i = 0; i < 30; i++) {
            new Thread(() -> {
                listSync.add(UUID.randomUUID().toString().substring(0, 8));
                // list.forEach(System.out::println);
                System.out.println(listSync);
            }, String.valueOf(i)).start();
        }
    }
}